<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table,
        th,
        td {
            border: 1px solid;
        }

        th,
        td {
            width: 100px;
            text-align: center;
        }
    </style>
</head>

<body>
    <table>
        <thead>
            <tr>
                <th>ID</th>
                <th>姓名</th>
                <th>年龄</th>
                <th>性别</th>
                <th>成绩</th>
                <th>电话</th>
            </tr>
        </thead>
        <tbody></tbody>
    </table>


    <script src="https://cdn.bootcdn.net/ajax/libs/Mock.js/1.0.1-beta3/mock-min.js"></script>
    <script>
        const tbody = document.querySelector('tbody');
        let data = Mock.mock({
            "list|18": [{
                'id|+1': 1, // 对象的 id 属性从 1 开始自增
                'name': '@cname',
                "score|50-100": 1,
                'age|16-25': 1,
                "gender|1": ["男", "女"],
                "phoneNumber": /^1[3458]\d{9}$/
            }]
        }).list;
        console.log(data);
        tbody.innerHTML = data.map(item =>
            ` 
                <tr>
                    <td>${item.id}</td>
                    <td>${item.name}</td>
                    <td>${item.age}</td>
                    <td>${item.gender}</td>
                    <td>${item.score}</td>
                    <td>${item.phoneNumber}</td>
                </tr>`
        ).join('')
        tbody.innerHTML
    </script>
</body>

</html>